# ----------------------------------------------------------------------------
# Copyright (c) Atg Robotics
# Author: Haotian Yu (haotianyuu@163.com)
# Data: 2022/03/11
# ----------------------------------------------------------------------------

d = {"sid": 10, "mid": 28, "eid": 46}
# print(d["id"])  # 抛出异常
print(d.get("id", 1))

newD = {}
for k in d.keys():
    newD.setdefault(k, None)
print(newD)

print("---------------")
print(list(d.keys()))
print(list(d.values()))
print(list(d.items()))


print("---------------")
def traverse(dic):
    if len(list(dic.keys())) <= 0: return
    print(dic.popitem())
    traverse(dic)
traverse(d)

# dict.update()没有返回值
d2 = {"lid": 15}
d.update(d2)
print(d)

